/* Modern UI Theme */
:root {
    --primary-color: #4f46e5;
    --primary-hover: #4338ca;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --danger-color: #ef4444;
    --background-color: #f8f9fa;
    --card-background: #ffffff;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --border-color: #e2e8f0;
    --header-height: 64px;
    --button-text: #ffffff;
    --tag-text: #374151;
    --pagination-text: #374151;
}

/* General styles */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--background-color);
    color: var(--text-primary);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.6;
    display: flex;
    flex-direction: column;
}

/* Navbar styles */
.navbar {
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    height: var(--header-height);
}

.navbar-brand {
    font-weight: 600;
    color: var(--primary-color) !important;
}

.nav-link {
    color: var(--text-secondary) !important;
    font-weight: 500;
    transition: color 0.2s ease;
}

.nav-link:hover {
    color: var(--primary-color) !important;
}

/* Main content styles */
.main-content {
    flex: 1;
    overflow-y: auto;
    padding: calc(var(--header-height) + 1rem) 1rem 1rem 1rem;
}

/* Card styles */
.card {
    background-color: var(--card-background);
    border: none;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin-bottom: 1rem;
}

.card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
}

.card-header {
    background-color: transparent;
    border-bottom: 1px solid var(--border-color);
    padding: 1.25rem 1.5rem;
}

.card-body {
    padding: 1.5rem;
}

/* File list styles */
.file-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.file-name {
    color: var(--text-primary);
    font-weight: 500;
    font-size: 0.95rem;
    word-break: break-word;
}

.text-muted {
    color: var(--text-secondary) !important;
    font-size: 0.85rem;
}

/* Table styles */
.table {
    background-color: var(--card-background);
    border-radius: 0.5rem;
    overflow: hidden;
    width: 100%;
}

.table th {
    background-color: var(--background-color);
    color: var(--text-secondary);
    font-weight: 600;
    padding: 1rem;
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 1rem;
    vertical-align: middle;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.table tbody tr:hover {
    background-color: var(--background-color);
}

/* Button styles */
.btn {
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background-color: var(--primary-color);
    border-color: var(--primary-color);
    color: var(--button-text);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    border-color: var(--primary-hover);
    color: var(--button-text);
}

.btn-success {
    background-color: var(--success-color);
    border-color: var(--success-color);
}

.btn-danger {
    background-color: var(--danger-color);
    border-color: var(--danger-color);
}

/* Badge styles */
.badge {
    color: var(--tag-text);
    font-weight: 500;
    background-color: #e5e7eb;
    padding: 0.35em 0.65em;
    margin: 0.2em;
    display: inline-block;
}

.badge:hover {
    transform: translateY(-1px);
}

/* Form styles */
.form-control {
    border-radius: 0.5rem;
    border: 1px solid var(--border-color);
    padding: 0.625rem 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
}

.form-control:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
}

/* PDF Viewer styles */
.pdf-viewer {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 60px); /* 减去顶部导航栏的高度 */
    background: #f8f9fa;
    margin: -1rem; /* 抵消container的padding */
}

.pdf-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 24px;
    background: white;
    border-bottom: 1px solid #e9ecef;
    z-index: 10;
}

.toolbar-buttons {
    display: flex;
    gap: 12px;
}

.toolbar-buttons .btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.toolbar-buttons .btn i {
    font-size: 1.1em;
}

.page-info {
    font-size: 0.95rem;
    color: #6c757d;
    display: flex;
    align-items: center;
    gap: 4px;
}

.pdf-container {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f1f3f4;
}

.pages-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    padding: 24px;
    background: #f1f3f4;
}

.pdf-page-container {
    margin: 0 auto 24px;
    display: flex;
    justify-content: center;
    background: white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-radius: 4px;
    max-width: 1000px; /* 限制在PC端的最大宽度 */
}

.pdf-page-container:last-child {
    margin-bottom: 0;
}

.pdf-page {
    max-width: 100%;
    height: auto;
    display: block;
    border-radius: 4px;
}

/* 全屏模式样式 */
.pdf-container:fullscreen {
    background: #2d3748;
    padding: 0;
}

.pdf-container:fullscreen .pages-container {
    padding: 20px;
    background: #2d3748;
}

.pdf-container:fullscreen .pdf-page-container {
    margin: 16px auto;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
    max-width: none; /* 全屏模式下取消最大宽度限制 */
}

/* 加载指示器 */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000;
    backdrop-filter: blur(4px);
}

/* 响应式设计 */
@media (max-width: 768px) {
    .pdf-viewer {
        height: calc(100vh - 56px);
    }

    .pdf-toolbar {
        padding: 8px 16px;
    }

    .pages-container {
        padding: 16px;
    }

    .pdf-page-container {
        margin: 0 auto 16px;
    }

    .toolbar-buttons .btn {
        padding: 6px 10px;
    }
}

/* 暗色模式 */
@media (prefers-color-scheme: dark) {
    .pdf-viewer {
        background: #1a1a1a;
    }

    .pdf-toolbar {
        background: #2d2d2d;
        border-bottom-color: #404040;
    }

    .page-info {
        color: #a0aec0;
    }

    .pdf-container {
        background: #262626;
    }

    .pages-container {
        background: #262626;
    }

    .pdf-page-container {
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    }

    .toolbar-buttons .btn-outline-primary {
        color: #81b4fe;
        border-color: #81b4fe;
    }

    .toolbar-buttons .btn-outline-primary:hover {
        background-color: #81b4fe;
        color: #1a1a1a;
    }
}

/* 滚动条美化 */
.pages-container::-webkit-scrollbar {
    width: 12px;
}

.pages-container::-webkit-scrollbar-track {
    background: transparent;
}

.pages-container::-webkit-scrollbar-thumb {
    background-color: rgba(155, 155, 155, 0.5);
    border-radius: 20px;
    border: 3px solid #f1f3f4;
}

.pages-container::-webkit-scrollbar-thumb:hover {
    background-color: rgba(155, 155, 155, 0.7);
}

@media (prefers-color-scheme: dark) {
    .pages-container::-webkit-scrollbar-thumb {
        border-color: #262626;
    }
}

/* Pagination styles */
.pagination {
    margin: 1rem 0;
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
}

.pagination .page-link {
    color: var(--pagination-text);
    background-color: var(--card-background);
    border-color: var(--border-color);
    margin: 0.2rem;
}

/* Mobile Responsive Styles */
@media (max-width: 768px) {
    /* Adjust header */
    .navbar {
        padding: 0.5rem;
    }
    
    /* Adjust main content padding */
    .main-content {
        padding: calc(var(--header-height) + 0.5rem) 0.5rem 0.5rem 0.5rem;
    }
    
    /* Make cards full width */
    .card {
        margin: 0.5rem 0;
        border-radius: 0.5rem;
    }
    
    /* Adjust table display for mobile */
    .table-responsive {
        margin: 0;
        padding: 0;
    }
    
    .table {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Stack form elements */
    .form-group {
        margin-bottom: 1rem;
    }
    
    /* Adjust buttons for mobile */
    .btn {
        width: 100%;
        margin: 0.25rem 0;
    }
    
    /* Make file info more compact */
    .file-info {
        padding: 0.5rem;
    }
    
    /* Adjust badges for mobile */
    .badge {
        margin: 0.2rem;
    }
    
    /* Adjust PDF viewer for mobile */
    .pdf-viewer-container {
        padding: 0.5rem;
    }
    
    /* Stack navigation items */
    .navbar-nav {
        padding: 0.5rem 0;
    }
    
    /* Improve form layout on mobile */
    .form-control {
        font-size: 16px; /* Prevent iOS zoom on focus */
    }
    
    /* Improve table readability on mobile */
    .table td, .table th {
        min-width: 120px;
        white-space: nowrap;
    }
    
    /* Add horizontal scroll for wide content */
    .table-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Additional tablet-specific adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .btn {
        padding: 0.5rem 0.75rem;
    }
    
    .card {
        margin: 0.75rem 0;
    }
    
    .main-content {
        padding: calc(var(--header-height) + 0.75rem) 0.75rem 0.75rem 0.75rem;
    }
}
